Skip to content

Thread mpi hypre - #125

Merged
maxpaik16 merged 3 commits into
mainfrom
thread-mpi-hypre
Nov 9, 2026
Merged

maxpaik16 merged 3 commits into
mainfrom
thread-mpi-hypre

Conversation

@maxpaik16

Copy link
Copy Markdown
Contributor

No description provided.

maxpaik16 and others added 3 commits November 6, 2026 15:17
nano-mpi allows one team of ranks per process, so solvers cannot each start
their own. Add mpi_utils/RankTeam: the first acquire() starts the ranks with
the calling thread as rank 0, the last release() joins them, and the driver
hands work to the other ranks with dispatch() or run(). Idle workers sleep on
a condition variable rather than waiting in an MPI collective, which spins in
nano-mpi.

CPUHybridSolver now uses it instead of its own team and command loop. Its
commands and solver code are unchanged. This also drops the worker-side
spdlog::set_level(off), which silenced every logger in the process.

Turn on HYPRE_ENABLE_THREAD_LOCAL in MPI builds. The switch to upstream hypre
left it off, so the rank threads shared hypre's global state, including the
random seed used in coarsening.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove a duplicated `extern "C" {` that left a brace unclosed and broke every
CUDA build.

GPUHybridSolver is one rank on one GPU, but it created its hypre objects on
MPI_COMM_WORLD. While another solver holds the nano-mpi ranks, that world has
members that take no part in the solve, and hypre's collectives would hang.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In MPI builds, Hypre now splits the rows across the nano-mpi ranks (threads
of this process, via RankTeam) and solves in parallel. NANOMPI_NUM_RANKS sets
the number of ranks; the default is the number of cores. Row ranges are made
of whole blocks so that no node is split between ranks. A solver used from a
thread that cannot drive the ranks solves on that thread alone.

"Hypre": {"use_gpu": true} runs hypre on the current CUDA device as a single
rank, with the same AMG options as GPUHybridSolver. It needs
POLYSOLVE_WITH_CUDA; otherwise set_parameters throws. Nodal coarsening has no
GPU implementation in hypre and is ignored there with a warning.

hypre's memory location and execution policy are now set around each call
instead of once in the constructor, so solvers on the same thread no longer
override each other's settings. interp_rbms is ignored with a warning: it
needs node positions the solver is never given, and was passing hypre empty
vectors.

Adds tests for several rank counts, more ranks than rows, use from another
thread, Hypre and CPUHybrid sharing the ranks, and the GPU option, and has CI
check Hypre's convergence at 1, 2 and 4 ranks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.65043% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.89%. Comparing base (621e8fb) to head (fd9ab77).

Files with missing lines Patch % Lines
src/polysolve/linear/HypreSolver.cpp 73.20% 56 Missing ⚠️
src/polysolve/linear/CPUHybridSolver.cpp 75.00% 12 Missing ⚠️
src/polysolve/linear/mpi_utils/RankTeam.cpp 89.01% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #125      +/-   ##
==========================================
+ Coverage   78.37%   78.89%   +0.52%     
==========================================
  Files          55       56       +1     
  Lines        2996     3127     +131     
  Branches      387      399      +12     
==========================================
+ Hits         2348     2467     +119     
- Misses        648      660      +12     
Flag Coverage Δ
polysolve 78.89% <77.65%> (+0.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maxpaik16
maxpaik16 merged commit 623a7ea into main Nov 9, 2026
17 checks passed
@maxpaik16
maxpaik16 deleted the thread-mpi-hypre branch November 9, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants